package com.nb.ds.controller;

import cn.hutool.json.JSONUtil;
import com.nb.ds.entity.Student;
import com.nb.ds.entity.User;
import com.nb.ds.mapper.UserMapper;
import com.nb.ds.service.IStudentService;
import com.nb.ds.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lihaoyang6
 * @date 2024年04月20日 16:30
 */
@RestController
@RequestMapping("test")
public class TestController {

    @Autowired
    IUserService userService;

    @Autowired
    IStudentService studentService;


    @GetMapping("listUser")
    public String listUser(){
        List<User> list =userService.findAll();
        return JSONUtil.toJsonStr(list);
    }

    @GetMapping("listStudent")
    public String listStudent(){
        List<Student> list =studentService.findAll();
        return JSONUtil.toJsonStr(list);
    }





    @GetMapping("add")
    public String add(){
        userService.add();
        return "OK~~~~~~~~~~";
    }
}
